import React from "react";
import { Text, View } from "react-native";

//Class组件

class ClassView extends React.Component {
    //构造函数
    constructor(props){
        super(props);

        // const {name,age,level} = props;
        // console.log(`name=${name},age=${age},level=${level}`)

        this.state = {
            adress:"江苏省南京市"
        }
        
    }

    //组间加载成功之后
    componentDidMount(){

        setTimeout(() => {
            this.setState ({
                adress:"河南省信阳市"
            });
        },2000);

    }
    //组间卸载时候
    componentWillUnmount(){

    }

    //渲染
    render(){

        const {name,age,level} = this.props;
        const {adress} = this.state;
        // console.log(`name1=${name},age1=${age},level1=${level}`)

        return(
            <View style={{width:200,height:200,backgroundColor:'blue'}}>
                <Text style = {{fontSize:20,color:'white'}}>
                     {`name=${name},age=${age},level=${level}`}
                </Text>
                <Text style = {{fontSize:20,color:"black"}}>
                    {adress}
                </Text>
            </View>
        )
    }
}

export default ClassView;